home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /////////////////////////////////////////////////////////////////////
- // ListView.h --
- /////////////////////////////////////////////////////////////////////
- #ifndef LISTVIEW_H
- #define LISTVIEW_H
-
- #include "Buttons.h"
- #include "Print.h"
- #include "GeneralPrefs.h"
- #include "Database.h"
-
- #include "OkLabeledComponent.h"
- #include "OkLabel.h"
- #include "OkText.h"
- #include "OkStrArray.h"
-
-
- #include <Vk/VkWindow.h>
- #include <Vk/VkMenu.h>
- #include <Vk/VkApp.h>
-
-
- #define MAX_CARD_VIEWS 8
- #define NO_ACTIVE_VIEWER -1
-
-
- class CardView;
- class CardInfo;
- class CardList;
- class OkFile;
- class ShowBtn;
- class DeleteBtn;
- class NewBtn;
- class ExportImportDialog;
-
- class ListView : public VkWindow {
-
- public:
- ListView();
- ~ListView();
- const char* className() { return "ListView"; }
-
- void showRolodexNameInTitle( const char* dbName );
- Boolean okToQuit();
-
- void setupFields();
- void setupAttributes();
-
- OkText* srchText() { return _srchText->component(); }
- CardList* cardList() { return _cardList; }
-
- void updateCardListFromCardInfo( unsigned pos, const CardInfo* cInfo );
- void updateCardListFromDb( const char* busyMsg=NULL );
-
- void setCardSensitivity();
- void setMenuAndBtnSensitivity();
- void updateIndicatorLabel( int cardNo=0 );
-
- void showCard( unsigned pos, CardInfo* cInfo=NULL );
- unsigned addCard( VkSimpleWindow* win=NULL );
- unsigned addCard( const char* name, CardInfo** );
- Boolean deleteCard( unsigned pos );
- Boolean deleteCard( unsigned pos, CardInfo* cInfo, VkSimpleWindow* win=NULL );
-
- int currCardNo() const { return _currCardNo; }
- int totalCards() const;
-
-
- ///////////////////////////////
- // Viewer manipulations.
- ///////////////////////////////
- void closeAllCardViews();
- int activeCardViewer() { return _activeCardViewer; }
- void setNoActiveCardViewer();
- void setActiveCardViewer( CardView* );
- void setActiveCardViewer( int n )
- { setActiveCardViewer( _cardViewTable[ n ] ); }
- Boolean noActiveCardViewer() const
- { return (_activeCardViewer==NO_ACTIVE_VIEWER); }
-
- void resetCardViewTableEntry( int i )
- { _cardViewTable[ i ] = NULL; }
- void saveAllCardViewChanges();
-
- void openFile( const char* fileName=NULL, Boolean openNew=FALSE );
- void save();
- void deleteAll();
-
- protected:
- void handleWmDeleteMessage() { quitCB( NULL, NULL, NULL ); }
-
- private:
-
- static VkMenuDesc mainMenuPane[];
- static VkMenuDesc fileMenuPane[];
- static VkMenuDesc cardMenuPane[];
- static VkMenuDesc prefsMenuPane[];
- static VkMenuDesc sortMenuPane[];
-
- // General Preference dialog.
- GeneralPrefDialog* _generalPrefDialog;
-
- // Export Import dialog.
- ExportImportDialog* _exportImportDialog;
-
- //////////////////////////////////////////////////////
- // Viewer Table.
- //////////////////////////////////////////////////////
- CardView* _cardViewTable[ MAX_CARD_VIEWS ];
- int _activeCardViewer;
-
- OkLabeledComponent<OkText>* _srchText;
- CardList* _cardList;
-
- ShowBtn* _showBtn;
- DeleteBtn* _deleteBtn;
- NewBtn* _newBtn;
-
- int _currCardNo;
-
- Widget _indicatorLabel;
-
- OkLabel* _listHeader;
-
-
- /////////////////////////////////////////////////////////////////
- // Callbacks.
- /////////////////////////////////////////////////////////////////
- // File menu:
- static void newFileCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->openFile( "", TRUE ); }
- static void openFileCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->openFile(); }
- static void saveCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->save(); }
- static void saveAsCB( Widget, XtPointer, XtPointer );
-
- static void importCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->import(); }
- static void exportCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->export(); }
-
- static void printAllCB( Widget, XtPointer, XtPointer )
- { thePrintCardDialog->printCardView(); }
- static void quitCB( Widget, XtPointer, XtPointer )
- { theApplication->quitYourself(); }
-
- // Card menu:
- static void searchCB( Widget, XtPointer, XtPointer );
- static void showCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->_showBtn->activate(); }
- static void deleteCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->_deleteBtn->activate(); }
- static void deleteAllCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->deleteAll(); }
- static void newCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->_newBtn->activate(); }
- // static void printCB( Widget, XtPointer obj, XtPointer ) {}
- static void closeAllCardViewsCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->closeAllCardViews(); }
-
- // Preferences menu:
- static void setupFieldsCB( Widget,XtPointer obj,XtPointer )
- { ((ListView *)obj)->setupFields(); }
- static void setupAttributesCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->setupAttributes(); }
-
- static void sortAscendingCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->sort( ASCENDING ); }
- static void sortDescendingCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->sort( DESCENDING ); }
-
- static void generalCB( Widget, XtPointer obj, XtPointer )
- { ((ListView *)obj)->_generalPrefDialog->post(); }
-
- // Keyboard callback.
- void checkEscKeyPress( XKeyEvent*, Boolean* b );
- static void checkEscKeyPressCB( Widget, XtPointer obj, XEvent* e, Boolean *b )
- { ((ListView *)obj)->
- checkEscKeyPress( (XKeyEvent*) e, b ); }
-
- /////////////////////////////////////////////////////////////////
- // Vk Callbacks.
- /////////////////////////////////////////////////////////////////
- void setAttrPrefChanged( VkComponent *dialog, void*, void* reason );
- void setAttrPrefChangedView( CardView* );
- void generalPrefChanged( VkComponent *dialog, void*, void* reason );
-
-
- /////////////////////////////////////////////////////////////////
- // Utility Funcs.
- /////////////////////////////////////////////////////////////////
- void export();
- void import();
- void sort( SortOrder );
-
- enum AdjustReason { ADD, DELETE };
- void adjustViewerCardPos( unsigned, AdjustReason );
-
- VkDialogManager::VkDialogReason openFileDialog( OkStr& fileName,
- const char* dialogTitle=NULL );
-
- };
-
-
- // This is the one and only ListView for the whole app.
- extern ListView* theListView;
-
- #endif
-